var fs=require('fs');

function route(handle,pathname,response){
    console.log('Routing a request for'+pathname);

    if(typeof handle[pathname]==='function'){
        handle[pathname](response);
    }else{
        console.log('no handler for'+pathname);
        fs.createReadStream(__dirname+'/404.html','utf8').pipe(response);
    }
}

module.exports.route=route;